<extend name="Layout/ins_page"/>
<block name="content">
    {:W('PageHeader/adv_search',array('name'=>'保险记录搜索','search'=>'M'))}
    <form method="post" name="form_adv_search" id="form_adv_search">
        <div class="adv_search panel panel-default  hidden" id="adv_search">
            <div class="panel-heading">
                <div class="row">
                    <h4 class="col-xs-6">高级搜索</h4>

                    <div class="col-xs-6 text-right">
                        <a class="btn btn-sm btn-info" onclick="submit_adv_search();">搜索</a>
                        <a class="btn btn-sm " onclick="close_adv_search();">关闭</a>
                    </div>
                </div>
            </div>
            <div class="panel-body">
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label" for="carNum">车牌号：</label>

                    <div class="col-sm-8">
                        <input class="form-control" type="text" id="carNum" name="carNum">
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label" for="type">投保种类：</label>

                    <div class="col-sm-8">
                        <input class="form-control" type="text" id="type" name="type">
                    </div>
                </div>

                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label" for="handle">办理人：</label>

                    <div class="col-sm-8">
                        <input class="form-control" type="text" id="handle" name="handle">
                    </div>
                </div>
                <div class="form-group col-sm-6">
                    <label class="col-sm-4 control-label" for="register_time">到期时间：</label>

                    <div class="col-sm-8">
                        <div class="input-daterange input-group">
                            <input type="text" class="input-sm form-control text-center" name="beginTime"
                                   readonly="readonly"/>
                            <span class="input-group-addon">-</span>
                            <input type="text" class="input-sm form-control text-center" name="endTime"
                                   readonly="readonly"/>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <div >
        <table data-toggle="table"    data-pagination="true"  data-page-list="[5,10,15]" data-page-size="5" data-unique-id="id" id="carTable" >
            <thead>
                <tr>
                    <th data-field="id">编号</th>
                    <th data-field="insuranceDate">时间</th>
                    <th data-field="carNum">车牌号</th>
                    <th data-field="type">投保种类</th>
                    <th data-field="money">投保金额</th>
                    <th data-field="company">投保公司</th>
                    <th data-field="hander">办理人</th>
                    <th data-field="expireDate">到期日</th>
                    <th data-field="remark">备注</th>
                    <th data-field="add_file">附件</th>
                    <if condition="$auth['admin']">
                         <th data-field="action" 	data-width="105" data-align="center">操作</th>
                    </if>
                </tr>
            </thead>
            <tbody>
               <volist name="insuranceList" id="insurance">
                   <tr >
                       <volist name="insurance" id="insuranceItem" >
                           <if condition="$key neq 'add_file'">

                               <td>
                                   {$insuranceItem}
                               </td>
                           <else/>
                               <td>

                                       <style>
                                           .file_list .tbody{
                                               border-width: 0px;
                                               line-height: inherit;
                                           }
                                       </style>
                                       <div class="col-sm-12">
                                           {:W('FileUpload/view',array('add_file'=>$insuranceItem,'mode'=>'show'))}
                                       </div>


                               </td>

                           </if>

                       </volist>
                       <if condition="$auth['admin']">
                           <td >
                                  <a class="btn btn-danger delete btn-xs" insuranceId="{$insurance['id']}" style="margin-top:2px;margin-bottom: 2px;" >删除</a>
                               <a class="btn btn-danger edit btn-xs" insuranceId="{$insurance['id']}"  style="margin-top:2px;margin-bottom: 2px;"  >编辑</a>
                           </td>
                       </if>
                   </tr>
               </volist>
            </tbody>
        </table>
    </div>

</block>
<block name="js">
    <script type="text/javascript">
        $(document).ready(function () {
            set_return_url();
             $("#form_search .btn-info").after("<a class='btn btn-sm btn-default' title='全部显示' href='"+"{:U('carInsurance')}"+"'><i class='fa fa-navicon'></i></a>");

//            $("#form_search .btn-info").after("<a class='btn btn-sm btn-danger' title='全部显示' href='"+"{:U('addInsurance')}"+"'><i class='fa fa-plus-square'></i></a>");



            $("#form_search input").attr("placeholder","输入车牌号查询");
            $("#form_search .input-group").width("300");

            $(".edit").on("click",function(event){
                winopen("{:U('editInsuranceById')}"+"?id="+$(this).attr('insuranceId'),704,570);
                $(".myFrame").attr("scrolling","yes");
            });

            $(".delete").on("click",function(event){
                var url = "{:U('Home/Car/deleteInsuranceById')}";
                var me = $(this);
                $.getJSON(url,{id:me.attr('insuranceId')},function(data){
                    if (data.status) {
                        ui_alert(data.info, function() {
                            parent.location.reload(true);
                            myclose();
                        });
                    }else{
                        ui_error(data.info);
                    }
                })
            });



        });
    </script>
</block>